#pragma once

// ANIP_FIXME: hide details of the template classes to reduce include
// overhead

#include "common.h"
#include "ui/ui.h"
#include "ui/control_base.h"
#include "texture.h"
#include "resource.h"
#include <map>
#include <vector>

// gcc/clang requires everything mentioned in the templates be included
#include "font.h"
#include "draw.h"

namespace anip
{
	class Texture2D;

	namespace ui
	{
		class Panel : public Scrollable<Container>
		{
		public:
			Panel(Container* parent, vec2 pos = { 0, 0 }, vec2 size = { 0, 0 });

			bcolor backColor = color{ 0, 0, 0, 0 };
			bcolor borderColor = color{ 0, 0, 0, 0 };
			bfloat borderWidth = 0;
			bfloat roundRadius = 0;

			void paint() override;
			void flow(Flow& f) override;
		};

		class FoldablePanel : public WithText<Panel>
		{
		private:
			vec2 _headerSize{ 0, 0 };
			float _contentHeight = 0;

		protected:
			int getTextWidth() override;
			void processMouseButton(MouseButton btn, ButtonAction action) override;

		public:
			FoldablePanel(Container* parent, vec2 pos = { 0, 0 }, vec2 size = { 0, 0 });

			// 0 = completely folded
			// 1 = fully expanded
			bfloat expandFactor = 1;
			bcolor headerColor = color{ 0.8f, 0.8f, 0.8f, 1 };

			void paint() override;
			void flow(Flow& f) override;

			void setText(const wstring& text) override;
			void setFont(const Font& font) override;
		};
	}
}